﻿#include<new>
#include<iostream>

using namespace std;

class OverFlow {};

int f(int x) {
	if (x < 0) {
		throw "奇怪，值为负\n";
	}
	else if (x > 30000) {
		throw OverFlow();
	}
	else {
		return 2 * x;
	}
}

int main() {
	int a;
	cout << "整数：";
	cin >> a;


	try {
		int b = f(a);
	}
	catch (const char* str) {
		cout << "发生异常：" << str;
	}
	catch (OverFlow) {
		cout << "程序溢出，结束程序\n";
		cin.get();
		cin.get();
		return 1;
	}

	cin.get();
	cin.get();
}